/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Merlion.MRP.entity;

import Merlion.SCM.entity.ProductEntity;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

@Entity
public class BillOfMaterialsEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @OneToOne(mappedBy = "BOMEntity")
    private ProductEntity product;
    private int batchSize;
    private String batchUnit;
    @OneToMany(mappedBy = "BOMEntity")
    private Collection<BillOfMaterialsEntryEntity> entries;

    public BillOfMaterialsEntity() {
    }

    public BillOfMaterialsEntity(ProductEntity product) {
        this.product = product;
    }

    public Collection<BillOfMaterialsEntryEntity> getEntries() {
        return entries;
    }

    public void setEntries(Collection<BillOfMaterialsEntryEntity> entries) {
        this.entries = entries;
    }

    public int getBatchSize() {
        return batchSize;
    }

    public void setBatchSize(int batchSize) {
        this.batchSize = batchSize;
    }

    public String getBatchUnit() {
        return batchUnit;
    }

    public void setBatchUnit(String batchUnit) {
        this.batchUnit = batchUnit;
    }

    public ProductEntity getProduct() {
        return product;
    }

    public void setProduct(ProductEntity product) {
        this.product = product;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BillOfMaterialsEntity)) {
            return false;
        }
        BillOfMaterialsEntity other = (BillOfMaterialsEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "mrp.BOMEntity[ id=" + id + " ]";
    }
    
}
